//
//  AsyncFunc.m
//  JFTwxsd
//
//  Created by Steven on 2018/9/17.
//  Copyright © 2018年 junfeiweiyejiaoyujituan. All rights reserved.
//

#import "AsyncFunc.h"


@implementation NSArray (Async)

- (AsyncFunc)reduce{
    
    if (self.count == 1) {
        return self.firstObject;
    }else if (self.count == 2){
        return concat(self[0], self[1]);
    }else{
        AsyncFunc resutlFunc = concat(self[0], self[1]);
        for (int i = 2; i< self.count; i++) {
            if (i == self.count - 1) {
                return concat(resutlFunc, self[i]);
            }else{
                resutlFunc = concat(resutlFunc, self[i]);
            }
        }
        return resutlFunc;
    }
}


@end
